package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.SelectVo;
import com.ruoyi.system.domain.vo.TreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsWarehouseBase;
import com.ruoyi.system.service.IWmsWarehouseBaseService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库基础信息Controller
 *
 * @author ruoyi
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/system/wmsWarehouseBase")
public class WmsWarehouseBaseController extends BaseController
{
    @Autowired
    private IWmsWarehouseBaseService wmsWarehouseBaseService;

    /**
     * 查询仓库基础信息列表
     */
    @SaCheckPermission("system:wmsWarehouseBase:list")
    @GetMapping("/list")
    public TableDataInfo<WmsWarehouseBase> list(WmsWarehouseBase wmsWarehouseBase, PageQuery pageQuery)
    {
        return wmsWarehouseBaseService.selectWmsWarehouseBaseList(wmsWarehouseBase,pageQuery);
    }

    /**
     * 导出仓库基础信息列表
     */
    /*@SaCheckPermission("system:wmsWarehouseBase:export")
    @Log(title = "仓库基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehouseBase wmsWarehouseBase)
    {
        List<WmsWarehouseBase> list = wmsWarehouseBaseService.selectWmsWarehouseBaseList(wmsWarehouseBase);
        ExcelUtil<WmsWarehouseBase> util = new ExcelUtil<WmsWarehouseBase>(WmsWarehouseBase.class);
        util.exportExcel(response, list, "仓库基础信息数据");
    }*/

    /**
     * 获取仓库基础信息详细信息
     */
    @SaCheckPermission("system:wmsWarehouseBase:query")
    @GetMapping(value = "/{warehouseId}")
    public R<WmsWarehouseBase> getInfo(@PathVariable("warehouseId") Long warehouseId)
    {
        return R.ok(wmsWarehouseBaseService.selectWmsWarehouseBaseByWarehouseId(warehouseId));
    }

    /**
     * 新增仓库基础信息
     */
    @SaCheckPermission("system:wmsWarehouseBase:add")
    @Log(title = "仓库基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsWarehouseBase wmsWarehouseBase)
    {
        return toAjax(wmsWarehouseBaseService.insertWmsWarehouseBase(wmsWarehouseBase));
    }

    /**
     * 修改仓库基础信息
     */
    @SaCheckPermission("system:wmsWarehouseBase:edit")
    @Log(title = "仓库基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsWarehouseBase wmsWarehouseBase)
    {
        return toAjax(wmsWarehouseBaseService.updateWmsWarehouseBase(wmsWarehouseBase));
    }

    /**
     * 删除仓库基础信息
     */
    @SaCheckPermission("system:wmsWarehouseBase:remove")
    @Log(title = "仓库基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseIds}")
    public R<Void> remove(@PathVariable Long[] warehouseIds)
    {
        return toAjax(wmsWarehouseBaseService.deleteWmsWarehouseBaseByWarehouseIds(warehouseIds));
    }

    /**
     * 查询商品品牌列表
     */
    @SaCheckPermission("system:wmsWarehouseBase:list")
    @GetMapping("/getWarehouseSelect")
    public R<List<SelectVo>> getWarehouseSelect(){
        return R.ok(wmsWarehouseBaseService.getWarehouseSelect());
    }

    /**
     * 查询仓库数据结构
     * @return
     */
    @SaCheckPermission("system:wmsWarehouseBase:query")
    @GetMapping("/queryWarehouseTree")
    public R<List<TreeVo>> queryWarehouseTree(){
        return  R.ok(wmsWarehouseBaseService.queryWarehouseTree());
    }
}
